<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
   var clickTreeId="";
   var areMainForm=true;
   function setting()
   {
      isperp.openDialog({
			title : '设置',
			contentUrl : "individuation/categoryPropertySetting/settingEdit?categoryId=" + clickTreeId+"&areMainForm="+areMainForm
		});
   }

	function categoryTree_onNodeClick(event, treeId, treeNode) {
		//alert(treeNode.treenodePath);
		//alert(	JSON.stringify(treeNode));
		/**/
		
		categoryPropertyGridA.search({
			"field" : "categoryId",
			"op" : "eq",
			"data" : treeNode.id
		});
		clickTreeId=treeNode.id;
		//判断是否主表单
		$.ajax({
		   url:"individuation/category/getOne?id="+clickTreeId,
		   success:function(data)
		   {
		      if(!data.areMainForm)
		      {
		        $("#categoryCreate").hide();
		        areMainForm=false;
		      }else
		      {
		        $("#categoryCreate").show();
		        areMainForm=true;
		      }
		   }
		});
		

	}

	function getCategoryTreeNode() {
		var node = individuationCategoryTree.zTree.getSelectedNodes();

		if (node && node != "") {
			return "categoryId=" + node[0].id;
		}

		alert("请选择一个节点");
		return false;
	};

	function category_BeforeDeleteFun(treeNode) {

		var result = "";
		$.ajax({
			type : "POST",
			url : "individuation/category/property/getPropertyCountByCategoryPath",
			data : "categoryPath=" + treeNode.treenodePath,
			dataType : "json",
			success : function(data) {
				if (data > 0) {

					result = "资产类别或子类别下存在自定义属性，您确定要全部删除？";
				}

			},
			async : false
		});
		
		return result;
	}
</script>
<div class="box no-border container_0 clearfix">
	<div class="box-left" style="width:20%;display:none" >
		<isperp:tree title="表单分类" modal="false" id="individuationCategoryTree"
			cusEditUrl="individuation/category/edit"
			cusDeleteUrl="individuation/category/delete">
			<isperp:async enable="true" url="individuation/category/getTree?showRoot=1">
			</isperp:async>
			<isperp:callback onClick="categoryTree_onNodeClick">
			</isperp:callback>
			<isperp:edit enable="true" showRemoveBtn="false"
				showRenameBtn="false"></isperp:edit>
			<isperp:view showTitle="false" addHoverDom="true"
				removeHoverDom="true"></isperp:view>
		</isperp:tree>
	</div>
	<div class="box-right" style="width:100%">
		
		
		<div class="header">
					<h2>表单</h2>
				</div>
				<isperp:grid url="individuation/individuationForm/list"
					gridId="categoryPropertyGridA" cusFormatterActions="true"
					showPager="false" showSearchbar="false" cusDialogSize="normal"
					cusEditUrl="individuation/individuationForm/edit"
					cusDeleteUrl="individuation/individuationForm/delete"
					ondbClickRowEvent="categoryPropertyGridA.edit(rowid);">

					<jsp:attribute name="toolbar">
	 				<isperp:toolbar id="categoryPropertyToolbar">
						<isperp:button id="categoryCreate" icon="icon-plus" text="新增表单"
								onclick="categoryPropertyGridA.create();"></isperp:button>
	 				</isperp:toolbar>
				 	</jsp:attribute>
					<jsp:body> 
					<isperp:column name="id" title="ID" hidden="true"></isperp:column> 
					<isperp:column name="name" title="名称"
							width="120">
					</isperp:column>
					
				</jsp:body>

				</isperp:grid>
		
		
		<isperp:operate code="COMMON_TREE_HELP"></isperp:operate>

	</div>
</div>